﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.Entity;
using EYSLibrary;


namespace EYayincilikSistemi
{
    public partial class signup : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            EYayincilikDBEntities entities = new EYayincilikDBEntities();
            var query = 
                        from kt in entities.KullaniciTuru
                        where kt.TurId < 3

                        select new { kt.TurId, kt.TurAdi};

            //+ ' '+k.Soyad
            cmbKulaniciTur.DataSource = query.ToList().AsQueryable();
            cmbKulaniciTur.DataTextField = "TurAdi";
            cmbKulaniciTur.DataValueField = "TurId";
            DataBind();
        }

        protected void Button1_Click(object sender, EventArgs e)
        {

            Kullanici K = new Kullanici();
            K.Ad = txtAd.Text;
            K.Soyad = txtSoyad.Text;
            K.KullaniciAdi = txtAd.Text;

            EYayincilikDBEntities edb = new EYayincilikDBEntities();
            edb.AddToKullanici(K);
            edb.SaveChanges();


            EYayincilikDBEntities edb2 = new EYayincilikDBEntities();
            Kullanici_KullaniciTuru kt = new Kullanici_KullaniciTuru();
            kt.KullaniciId = Convert.ToInt32(K.Id);
            kt.KullaniciTuruId = Convert.ToInt32(cmbKulaniciTur.SelectedValue.ToString());


            edb2.AddToKullanici_KullaniciTuru(kt);
            edb2.SaveChanges();
        }
    }
}